<template>	
		<view class="hot_sku">
			<view class="hot_sku_list">
				<view class="sku" v-for="sku in skuList">
					<image class="sku_image" :src="sku.image"></image>
					<view class="sku_price">
						<text>￥{{sku.price}}</text>
						<text>￥{{sku.origanlPrice}}</text>
					</view>
					<view class="sku_name">{{sku.name}}</view>
				</view>
			</view>
		</view>
</template>

<script>
	export default {
		data() {
			return {
				skuList:{} // 推荐商品
			}
		},
		onLoad() {
			console.log('--onload--start')
			this.fetchBanners()
			console.log('--end--start')
		},
		onReachBottom() {
			console.log("我到底了")
		},
		onPullDownRefresh() {
			console.log("刷新本页")
			this.$forceUpdate();
			console.log("刷新本页2")
			uni.stopPullDownRefresh();
		},
		methods: {
			fetchBanners() {
				uni.request({
				  url: '/pages/shopping/shopping.json', // 你的JSON文件地址
				  method: 'GET',
				  success: (res) => {
				    if (res.statusCode === 200) {
				      // 请求成功，处理数据
					  console.log("banner2", res.data);
					  this.skuList = res.data.sku.list
				    } else {
				      // 请求失败处理
				      console.error('请求失败1', res.statusCode);
				    }
				  },
				  fail: (err) => {
				    // 请求发生错误处理
				    console.error('请求出错2:', err);
				  }
				});
			}
		}
	}
</script>

<style>
.hot_sku {
		background:#eee;
		margin-top:10px;
		overflow:hidden;
	}
	.hot_sku_head {
		background: #fff;
		height:50px;
		line-height:50px;
		color:#e2211c;
		text-align:center;
		letter-spacing:20px;
		margin:5px;
	}
	
	.hot_sku_list {
		display:flex;
		flex-wrap:wrap;
		justify-content: space-between;
	}
	
	.sku{
		background:#fff;
		width:355rpx;
		margin:5px;
		padding:5px;
		box-sizing: border-box;
	}
	
	.sku_image {
		width:80%;
		height:150px;
		display:block;
		margin:0 auto;
	}
	.sku_price {
		color:#e2211c;
		font-size:38rpx;
		margin:5px;
		text:nth-child(2) {
			color:#ccc;
			font-size:28rpx;
			margin-left:18px;
			text-decoration: line-through;
		}
	}
	.sku_name {
		font-size:38rpx;
		line-height: 50rpx;
		margin:5px;
	}
</style>
